import Cookies from 'js-cookie'

const seconds = 3600

const expires = new Date(new Date() * 1 + seconds * 1000)

// 1. token的本地化操作
const TokenKey = 'hrsaas-ihrm-token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token, { expires })
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// 2. 时间戳的本地操作
const TimeKey = 'hrsaas-timestamp-key' // 设置一个独一无二的key

export function getTimeStamp() {
  return Cookies.get(TimeKey)
}

export function setTimeStamp() {
  return Cookies.set(TimeKey, Date.now(), { expires: 1 })
}
